﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SLTest.aspx.cs" Inherits="ELS.Platform.NursingSkills.UI.Web.Admin.ContentEditor.SLTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
   <div id="silverlightHost" style="position:absolute; top:0; left:0; width:0px; height:0px; z-index:100" 	>

        <script type="text/javascript" src="Silverlight.js"></script>

        <script type="text/javascript" id="horst">
           function launchUploader() {
                doc = document.getElementById("silverlightHost");
                doc.style.width = "100%";
                doc.style.height = "100%";
                doc.style.zIndex = 100;
                
                var getSilverlightMethodCall =
            "javascript:Silverlight.getSilverlight(\"4.0.50401.0\");"
                var installImageUrl =
            "http://go.microsoft.com/fwlink/?LinkId=161376";
                var imageAltText = "Get Microsoft Silverlight";
                var altHtml =
            "<a href='{1}' style='text-decoration: none;'>" +
            "<img src='{2}' alt='{3}' " +
            "style='border-style: none'/></a>";
                altHtml = altHtml.replace('{1}', getSilverlightMethodCall);
                altHtml = altHtml.replace('{2}', installImageUrl);
                altHtml = altHtml.replace('{3}', imageAltText);

                Silverlight.createObject(
                "ClientBin/ImageUploaderComponant.xap",  // source
                silverlightHost,  // parent element
                "slPlugin",  // id for generated object element
                {width: "100%", height: "100%", background: "#00000000", windowless: "true"
            },
                { onError: onSilverlightError, onLoad: onSLLoad },
                "skillKeyId=<%# ContentKeyId %>,clientId=<%# ClientId %>,userId=<%# UserId %>, skillId=<%#SkillId%>, skillName=<%#SkillName%>",
                "context"    // context helper for onLoad handler.        );
                )
            };
            
            function destroySilverlightWindow() {
                doc = document.getElementById("silverlightHost");
                doc.style.width = "0%";
                doc.style.height = "00%";
                doc.style.zIndex = -1;
            }
        
        function onSLLoad(plugIn, userContext, sender) {
            window.status +=
                plugIn.id + " loaded into " + userContext + ". ";
        }

        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }

            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
                return;
            }

            var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
        launchUploader();
        </script>

    </div>
    </form>
</body>
</html>
